import io from 'socket.io-client';
window.socket = io('http://localhost:3000');
export default {
    socket,
    addRoomName(data, fn) {
        this.socket.emit('join', data);
    },
    removeRoomName(data, fn) {
        this.socket.emit('leave', data);
    },
    addContent(data, fn) {
        this.socket.emit('chat message', data);
    },
    getContent(fn) {
        this.socket.on('chat message', function(msg) {
            return msg;
        });
    },
    userOnline(data, fn) {
        this.socket.emit('online', data);
        if (typeof fn === 'function') fn(data);
    },
    userFriendMsg(uid, fid, msg, fn) {
        this.socket.emit('user message', uid, fid, msg);
    },
};
